package com.geekaca;

import com.geekaca.config.MySpringConfig;
import com.geekaca.domain.Brand;
import com.geekaca.domain.BrandType;
import com.geekaca.service.BrandService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.List;

public class BrandMain {
    private static ApplicationContext ctx = new AnnotationConfigApplicationContext(MySpringConfig.class);
    private static BrandService brandService = (BrandService) ctx.getBean("brandService");

    public static void main(String[] args) {
//        addBrand();
        selectBrands();


    }

    public static void addBrand() {
        BrandType brandType = new BrandType(2, 2, "数码");
        Brand brand = new Brand(null, "苹果牌", "苹果公司", 22, "科技美学", 1, 2, brandType);
        int i = brandService.addBrand(brand);
        System.out.println("插入了：" + i + " 条数据。");
    }

    public static void selectBrands(){
        List<Brand> brands = brandService.selectBrands();
        System.out.println(brands);
    }

}
